package com.zeta.eduservice.controller.file;


import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.sql.rowset.serial.SerialArray;

import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.zeta.commonutils.R;
import com.zeta.eduservice.entity.question.QuestionFile;
import com.zeta.eduservice.service.QuestionFileService;

import ch.qos.logback.classic.sift.SiftAction;

/**
 * <p>
 * 题文件表 前端控制器
 * </p>
 *
 * @author zeta
 * @since 2020-09-05
 */
@CrossOrigin
@RestController
@RequestMapping("/eduservice/question_file")
public class QuestionFileController {
	@Autowired
	private QuestionFileService fileService;
	@GetMapping("/getAllByUserId/{userid}")
	public R getAllByUserId(@PathVariable(value="userid") String userid) {
		QueryWrapper<QuestionFile> queryWrapper=new QueryWrapper<QuestionFile>();
		queryWrapper.eq("userid",userid);
		List<QuestionFile> list = fileService.list(queryWrapper);
		return R.ok().data("fileList",list);
		
	}
	@PostMapping("userUpload")
	public R userUpload(MultipartFile file,HttpServletRequest request) {
		fileService.userUpload(file,request);
		//获取文件原名称
		return R.ok();
		
	}
	
	
	
}

